home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / QuickTime / ChromaKeyMovie / Sources / doevent.c < prev    next >
Encoding:
Text File  |  1995-11-20  |  3.9 KB  |  198 lines  |  [TEXT/MPS ]

  1. /****************************************************/
  2. /*                                                     */
  3. /*    File:    doevent.c                                   */
  4. /*                                                    */
  5. /*    Program:    ChromaKeyMovie                        */
  6. /*                                                    */
  7. /*    By:        Jason Hodges-Harris                        */
  8. /*                                                    */
  9. /*    Copyright:    © 1995 by Apple Computer, Inc.,        */ 
  10. /*                    all rights reserved.            */        
  11. /*                                                    */
  12. /****************************************************/
  13.  
  14.  
  15.  
  16.  
  17. // Mac toolbox headers
  18.  
  19. #ifndef __CURSORCTL__
  20. #include <CursorCtl.h>
  21. #endif
  22.  
  23. #ifndef __DESK__
  24. #include <Desk.h>
  25. #endif
  26.  
  27. #ifndef __DISKINIT__
  28. #include <DiskInit.h>
  29. #endif
  30.  
  31. #ifndef __EVENTS__
  32. #include <Events.h>
  33. #endif
  34.  
  35. #ifndef __MENUS__
  36. #include <Menus.h>
  37. #endif
  38.  
  39. #ifndef __MOVIES__
  40. #include <Movies.h>
  41. #endif
  42.  
  43. #ifndef __QDOFFSCREEN__
  44. #include <QDOffscreen.h>
  45. #endif
  46.  
  47. #ifndef __TOOLUTILS__
  48. #include <ToolUtils.h>
  49. #endif
  50.  
  51. #ifndef __WINDOWS__
  52. #include <Windows.h>
  53. #endif
  54.  
  55.  
  56. // Program headers
  57.  
  58. #ifndef __CHROMAPPHEADER__
  59. #include "ChromaKeyMovie.app.h"
  60. #endif
  61.  
  62. #ifndef __CHROMAPROTOSHEADER__
  63. #include "ChromaKeyMovie.protos.h"
  64. #endif
  65.  
  66. //    Global Variables
  67.  
  68. extern short            gKeyMode;
  69. extern Boolean            gMovieOpen;
  70.  
  71.  
  72. // DoEvent function processess the events posted by the application.
  73. // This includes the handling of the movie controller, mouse, key,
  74. // disk and operating system events.
  75.  
  76. #pragma segment Main
  77. void DoEvent (EventRecord *eventPtr)
  78. {
  79.     WindowPtr        theWindow,
  80.                     theTempWindow;
  81.     char            theChar;
  82.     
  83.     theWindow = FrontWindow();
  84.     theTempWindow = theWindow;
  85.     if (gMovieOpen)
  86.     {
  87.         while (theTempWindow != nil)
  88.         {
  89.             MCIsPlayerEvent((**((MovieDocHndl)
  90.                 GetWRefCon(theTempWindow))).theController,eventPtr);
  91.             theTempWindow = &(*(((WindowPeek)theTempWindow)->nextWindow)).port;
  92.         }
  93.     }
  94.     switch (eventPtr->what)
  95.     {
  96.         case nullEvent:
  97.             if (gMovieOpen)
  98.             {
  99.                 switch (gKeyMode)
  100.                 {
  101.                     case transparentMode:
  102.                         TransparentKeyMode(theWindow);    // use transparent transfer mode
  103.                     break;
  104.                     case graphix:
  105.                     break;
  106.                     case modifierTrax:
  107.                     break;
  108.                 }
  109.             }
  110.         break;
  111.         case mouseDown:
  112.             HandleMouseDown(eventPtr);
  113.         break;
  114.         case mouseUp:
  115.         break;
  116.         case keyDown:
  117.         case autoKey:
  118.             theChar=eventPtr->message & charCodeMask;
  119.             if ((eventPtr->modifiers &cmdKey) !=0)
  120.                 DoMenuCommand(MenuKey (theChar));
  121.         break;
  122.         case keyUp:
  123.         break;
  124.         case updateEvt:
  125.             DoWindUpdate((WindowPtr)(eventPtr->message));
  126.         break;
  127.         case diskEvt:
  128.             DoDiskEvt(eventPtr);    // disk inserted event
  129.         break;
  130.         case osEvt:
  131.             if (eventPtr->message>>24==resumeFlag)
  132.             //Show_Cursor(ARROW_CURSOR); // reset cursor
  133.                 SetCursor(&qd.arrow);
  134.         break;
  135.     }
  136. }
  137.  
  138.  
  139. // HandleMouseDown controls the further processing of mouse button down events.
  140. // This includes testing the location of the mouse pointer at the time of the event
  141. // and performing the appropriate action. e.g. if the mouse button was pressed
  142. // whilst the pointer was in the menubar, the value returned by MenuSelect()
  143. // (used to determine which menubar and item selected) is passed into DoMenuCommand()
  144. // which in turn handles the processing of the selected menu items.
  145.  
  146. #pragma segment Main
  147. void HandleMouseDown(EventRecord *eventPtr)
  148. {
  149.     WindowPtr    window;
  150.     short        thePart;
  151.     long        menuChoice;
  152.     
  153.     thePart=FindWindow (eventPtr->where,&window);
  154.     switch (thePart)
  155.     {
  156.         case inMenuBar:
  157.             menuChoice = MenuSelect (eventPtr->where);
  158.             DoMenuCommand(menuChoice);
  159.             break;
  160.         case inSysWindow:
  161.             SystemClick(eventPtr,window);
  162.             break;
  163.         case inDrag:
  164.             DragSelWind(window,eventPtr->where);
  165.         case inGoAway:
  166.             DoGoAwayWind(window,eventPtr->where);
  167.         break;
  168.         case inContent:
  169.             {
  170.                 if(window!=FrontWindow())
  171.                 {
  172.                     SelectWindow(window);
  173.                     break;
  174.                 }
  175.             }
  176.         break;
  177.         case osEvt:
  178.         break;
  179.     }
  180. }
  181.  
  182.  
  183. // DoDiskEvt handles the event post by the OS when a disk is insert
  184. // and displays an error is the media cannot be mounted.
  185.  
  186. #pragma segment Main
  187. void DoDiskEvt(EventRecord *eventPtr)
  188. {
  189.     short    ErrResult;
  190.     Point    ErrPoint;
  191.  
  192.     if((HiWord(eventPtr->message)!=noErr))
  193.     {
  194.         SetPt(&ErrPoint,100,100);
  195.         ErrResult=DIBadMount(ErrPoint,eventPtr->message);
  196.     }
  197. }
  198.